package com.xx.pmis.services.implementations;

import java.util.List;

import com.xx.pmis.model.Subject;
import com.xx.pmis.persistence.dao.SubjectDAO;
import com.xx.pmis.services.SubjectService;

public class SubjectServiceImpl implements SubjectService {
	SubjectDAO subjectDAO = null;

	public SubjectServiceImpl(SubjectDAO subjectDAO) {
		super();
		this.subjectDAO = subjectDAO;
	}

	public void saveOrUpdateSubject(Subject subject) throws Exception {
		subjectDAO.saveOrUpdate(subject);
	}

	public void saveSubject(Subject subject) throws Exception {
		subjectDAO.save(subject);
	}

	public void deleteSubject(Subject subject) throws Exception {
		subjectDAO.delete(subject);
	}

	public Subject getSubjectBySubjectID(String subjectID) throws Exception {
		Subject subject = subjectDAO.getSubjectBySubjectID(subjectID);
		return subject;
	}

	public List<Subject> getAllSubjectByCondition(String hql) throws Exception {
		List<Subject> subjects = subjectDAO.getAllSubjectByCondition(hql);
		return subjects;
	}

	public int getCountOfSubject(String hql) throws Exception {
		return subjectDAO.getAllSubjectByCondition(hql).size();
	}

}
